/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * VentanaPrincipal.java
 *
 * Created on 04/07/2010, 09:31:14 PM
 */

package com.quantum4g.gui.componentes;

/**
 *
 * @author Jose
 */
public class VentanaPrincipal extends javax.swing.JFrame {

    /** Creates new form VentanaPrincipal */
    public VentanaPrincipal() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnIniciarExperimento = new javax.swing.JButton();
        lblTitle = new javax.swing.JLabel();
        lblIteraciones = new javax.swing.JLabel();
        lblN = new javax.swing.JLabel();
        lblVelocidad = new javax.swing.JLabel();
        txtIteraciones = new javax.swing.JTextField();
        txtN = new javax.swing.JTextField();
        cmbVelocidad = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Quantum4G");

        btnIniciarExperimento.setText("Iniciar Experimento");
        btnIniciarExperimento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnIniciarExperimentoActionPerformed(evt);
            }
        });

        lblTitle.setText("Experimento Principal");

        lblIteraciones.setText("Iteraciones");

        lblN.setText("N");

        lblVelocidad.setText("Velocidad");

        cmbVelocidad.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Lento", "Normal", "Rapido" }));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(btnIniciarExperimento))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGap(27, 27, 27)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblTitle, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lblIteraciones)
                                    .addComponent(lblN)
                                    .addComponent(lblVelocidad))
                                .addGap(47, 47, 47)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(cmbVelocidad, 0, 149, Short.MAX_VALUE)
                                    .addComponent(txtN, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE)
                                    .addComponent(txtIteraciones, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE))))))
                .addContainerGap(33, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblTitle)
                .addGap(33, 33, 33)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblIteraciones)
                    .addComponent(txtIteraciones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lblN)
                    .addComponent(txtN, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblVelocidad)
                    .addComponent(cmbVelocidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(26, 26, 26)
                .addComponent(btnIniciarExperimento)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnIniciarExperimentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIniciarExperimentoActionPerformed
        // TODO add your handling code here:
        int iteraciones=10;
        int N=10;
        int velocidad=1;

        velocidad=2-this.cmbVelocidad.getSelectedIndex();
        try{
            iteraciones=Integer.parseInt(this.txtIteraciones.getText());
        }
        catch (NumberFormatException ex){
            iteraciones=10;
        }
        try{
            N=Integer.parseInt(this.txtN.getText());
        }
        catch (NumberFormatException ex){
            N=10;
        }
        VentanaExperimento ventanaE=new VentanaExperimento(velocidad,N,iteraciones);
        ventanaE.setVisible(true);
    }//GEN-LAST:event_btnIniciarExperimentoActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VentanaPrincipal().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnIniciarExperimento;
    private javax.swing.JComboBox cmbVelocidad;
    private javax.swing.JLabel lblIteraciones;
    private javax.swing.JLabel lblN;
    private javax.swing.JLabel lblTitle;
    private javax.swing.JLabel lblVelocidad;
    private javax.swing.JTextField txtIteraciones;
    private javax.swing.JTextField txtN;
    // End of variables declaration//GEN-END:variables

}
